package main

import (
	"flag"

	"github.com/zeromicro/go-zero/tools/goctl/api/gogen/workspace/internal/config"
	"github.com/zeromicro/go-zero/tools/goctl/api/gogen/workspace/internal/handler/greet"
	"github.com/zeromicro/go-zero/tools/goctl/api/gogen/workspace/pkg/conf"
)

type Serve interface {
	Run() error
}

const (
	Greet = "greet"

	// add other module
)

var configFile = flag.String("f", "../etc/user.yaml", "the config file")

func main() {
	flag.Parse()
	args := flag.Args()
	if len(args) == 0 {
		panic("请指定运行模式")
	}

	var cfg config.Config
	conf.MustLoad(*configFile, &cfg)

	var srv Serve
	switch args[0] {
	case Greet:
		srv = greet.NewHandle(cfg)
	// add other module case
	default:
		panic("请指定正确的服务")
	}

	srv.Run()
}
